package com.cn.kabalifemerchants.ui.user.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.cn.kabalifemerchants.R;
import com.cn.kabalifemerchants.base.IBaseActivity;
import com.cn.kabalifemerchants.config.LoginHelper;
import com.cn.kabalifemerchants.ui.user.FragmentUserPresenter;
import com.cn.kabalifemerchants.ui.user.FragmentUserView;
import com.cn.kabalifemerchants.ui.user.bean.MyUserInfoBean;
import com.cn.kabalifemerchants.utils.GlideUtil;
import com.cn.kabalifemerchants.utils.RxToast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 晓林 on 2020/10/21.
 * function:
 */
public class IMoneyActivity extends IBaseActivity<FragmentUserView, FragmentUserPresenter> implements FragmentUserView {
    @BindView(R.id.tv_money_all)
    TextView tvMoneyAll;
    @BindView(R.id.tv_money)
    TextView tvMoney;

    @Override
    protected FragmentUserPresenter createPresenter() {
        return new FragmentUserPresenter();
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_money;
    }

    @Override
    public void onReLoggedIn(String msg) {

        RxToast.error(msg);
        LoginHelper.againGoToLoginActivity(getMe());
    }

    @Override
    public void onError(String msg) {
        RxToast.error(msg);
    }

    @Override
    public Context _getContext() {
        return getMe();
    }

    @Override
    public void onUserInfoSuccess(MyUserInfoBean bean) {
        tvMoneyAll.setText(String.valueOf(bean.getResult().getZong_money()));
        tvMoney.setText(String.valueOf(bean.getResult().getMoney()));

    }

    @Override
    public void onResume() {
        super.onResume();
        mPresenter.onUserInfoData(LoginHelper.getLonginData().getResult());
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        setTitleBar("我的钱包");
    }


    @OnClick({R.id.tv_btn_tx, R.id.ll_btn_details})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_btn_tx:
                $startActivity(IMoneyTiXianActivity.class);
                break;
            case R.id.ll_btn_details:
                $startActivity(FinancialDetailsActivity.class);
                break;
        }
    }
}
